package com.itheima.homework;

import java.util.Scanner;

/*
    键盘录入一个字符串，统计该字符串中大写字母字符，
    小写字母字符，数字字符出现的次数(不考虑其他字符)
*/
public class HomeWork4 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入一个字符串");
        //键盘录入一个字符串
        String s=sc.nextLine();
        int bigCount=0;
        int smallCount=0;
        int numCount=0;
      /*  //遍历字符串charAt()方法
        for (int i = 0; i <s.length() ; i++) {
            char c=s.charAt(i);
            if(c>='a'&&c<='z'){
                smallCount++;
            }else if(c>='A'&&c<='Z'){
                bigCount++;
            }else if(c>='0'&&c<='9'){
                numCount++;
            }
        }*/
        //遍历字符串toCharArray()
        char[] chs=s.toCharArray();
        for (int i = 0; i <chs.length ; i++) {
            if(chs[i]>='a'&&chs[i]<='z'){
                smallCount++;
            }else if(chs[i]>='A'&&chs[i]<='Z'){
                bigCount++;
            }else if(chs[i]>='0'&&chs[i]<='9'){
                numCount++;
            }
        }
        System.out.println("大写字母有"+bigCount+"个");
        System.out.println("小写字母有"+smallCount+"个");
        System.out.println("数字字符有"+numCount+"个");
    }
}
